<?php

namespace App;

use DB;

class Order extends Model
{
   	public $table = 'orders';

   	public function goodsName()
   	{
   		$order_goods = OrderGoods::where(['order_sn' => $this->order_sn])->first();
   		$goods = Goods::where(['goods_id' => $order_goods->goods_id])->first();
   		return $goods->goods_name;
   	}

   	public function goodsCount()
   	{
         $order_goods = OrderGoods::where(['order_sn' => $this->order_sn])->first();
   		return $order_goods->count;
   	}

      public function user()
      {
         return $this->belongsTo('App\User', 'user_id', 'userid');
      }
}
